<!DOCTYPE html>
<html lang="en">
<!--头部信息-->
<head>
    <meta charset="utf-8">
    <title>地狱操作</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">

    <script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>

    <style>
        body {
            background-color: #ffffff;
        }

        .common {
            text-align: center;
            float: right;
            font-size: 18px;
            padding-left: 5px
        }
    </style>

</head>
<!--地狱操作(弹出层)-->
<body>
<div class="layui-form layuimini-form">
    <div class="layui-container" style="padding-right: 30px">

        <div class="layui-row">
            <div class="layui-col-md2">
                <div class="grid-demo grid-demo-bg1">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="grid-demo common" style="font-size: 15px;padding-right: 180px">
                    <p>该用户平生作恶多端</p>
                    <p>即刻打入地狱</p>
                </div>
            </div>
            <div class="layui-col-md2">
                <div class="grid-demo grid-demo-bg1">
                </div>
            </div>
            <br>
            <br>
            <br>
            <br>
            <!--地狱层级-->
            <div class="layui-form-item">
                <label class="layui-form-label">地狱层级：</label>
                <div class="layui-input-block">
                    <select name="dycj" id="dycj">
                        <option value="">请选择</option>
                    </select>
                </div>
            </div>


            <!--受刑时间-->
            <div class="layui-form-item">
                <label class="layui-form-label">受刑时间：</label>
                <div class="layui-input-block">
                    <input type="text" id="sxsj" name="sxsj" class="layui-input">
                </div>
            </div>
            <br>
            <!--确定-->
            <div class="layui-form-item">
                <div class="layui-input-block" style="float: left;width: 300px;padding-left: 60px">
                    <button style="width: 200px" type="button" class="layui-btn layui-btn-danger" lay-submit
                            lay-filter="saveBtn">打入地狱
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<div style="display: none">
    <input type="text" value="" id="ids">
    <input type="text" value="" id="names">
    <input type="text" value="" id="ind">
    <input type="text" value="" id="info">
    <input type="text" value="" id="id">
</div>


<script>
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.jquery;

        getDycj();

        /*初始化【地狱】下拉列表框*/
        function getDycj() {
            $.ajax({
                type: 'GET',
                url: '/getEighteenLevel',
                dataTypel: 'json',
                success: function (data) {
                    for (var i = 0; i < data.length; i++) {
                        $("#dycj").append("<option value=\"" + data[i].level + "\">" + data[i].eightName +
                            "</option>");
                        $("#dycj").val("");
                    }
                    layui.form.render("select");
                }
            })
        }


        /*打入地狱事件处理*/
        form.on('submit(saveBtn)', function (data) {
            var na = $("#names").val();
            var info = {
                dycj: $("#dycj").val(),
                year: $("#sxsj").val(),
                userID: $("#ids").val(),
                userName: $("#names").val(),
                info: $("#info").val()
            }
            layer.confirm("确认把" + na + "打入地狱吗？", {icon: 3}, function (index) {
                /*发送打入地狱请求*/
                $.ajax({
                    type: 'POST',
                    dataType: 'text',
                    url: '/sendDiyu/' + $("#id").val(),
                    data: {dyInfo: JSON.stringify(info)},
                    error: function () {
                        layer.alert("系统错误！");
                    },
                    success: function (result) {
                        if (result === 'success') {
                            layer.alert('成功将' + na + "打入地狱!",
                                {
                                    title: '成功',
                                    skin: 'layui-layer-molv',
                                    btn: ['返回'],
                                    anim: 1,
                                    icon: 6,
                                    yes: function () {
                                        parent.layer.closeAll('iframe');
                                    }
                                });
                        } else {
                            layer.alert('打入地狱失败，继续吗？',
                                {
                                    title: '错误',
                                    skin: 'layui-layer-molv',
                                    btn: ['重试', '退出'],
                                    anim: 1,
                                    icon: 5,
                                    yes: function (index) {
                                        layer.close(index);
                                    },
                                    btn2: function () {
                                        layer.close(index);
                                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                                    }
                                });
                        }
                    }
                });
            });
            return false;
        })
    })
</script>
</body>
</html>